package com.kyh.util.word;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.commons.io.FileUtils;

import com.kyh.util.word.WordUtil;

public class WordGenerateUtil {

	public static void main(String[] args) {
	}
	
	/*
	public static void generateWord(String pathDirTo, String pathTempletDOC,
			Receive receive,
			Merchantns merchantns,
			Personns personns,
			String foldername
			) {
		

		// 循环遍历收款ID
			
		// 导出word
		WordUtil msWordManager = new WordUtil();
		try {
			// 要生成的word路径
			String dirPath = pathDirTo + "/" + foldername;
			String filePath = dirPath + "\\申请表.doc";
			FileUtils.copyFile(new File(pathTempletDOC), new File(filePath), true);
			msWordManager.openDocument(filePath);
			msWordManager.replaceAllText("$personnsname", personns.getPersonnsname());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$merchantnscode", merchantns.getMerchantnscode());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$merchantnsname", merchantns.getMerchantnsname());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$merchantnsaddr", merchantns.getMerchantnsaddr());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$personnsidcardno", personns.getPersonnsidcardno());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$receivename", receive.getReceivename());
			msWordManager.moveStart();
			msWordManager.replaceAllText("$personnsbankcardno", personns.getPersonnsbankcardno());
			msWordManager.closeDocument(-1);
			File file = new File(filePath);
			System.out.println("生成的文件路径===" + file.getPath());
			
			File dirFile = new File(dirPath);
			if (!dirFile.exists()) {
				dirFile.mkdirs();
			}
			
			InputStream fis = new BufferedInputStream(new FileInputStream(file));
			byte[] buffer = new byte[fis.available()];
			fis.read(buffer);
			fis.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			msWordManager.close();
		}
	}
	*/
}
